package com.tod.security.springsecuritydbencrypt.controller;

import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.security.Principal;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Tod.xie
 * Date: 2018-02-05
 * Time: 11:18
 *
 * @author Tod.xie
 */
@Controller
public class UserController {
    @GetMapping("/user")
    public String user(@AuthenticationPrincipal Principal principal, Model model){
        model.addAttribute("username", principal.getName());
        return "user/user";
    }

}
